<template>
    <van-nav-bar title="标题" left-text="返回" left-arrow @click-left="onClickLeft" />
    <div>
        <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
            <van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
                <van-card v-for="(item, index) in arr" :key="index" :price="item.goods_price" :title="item.goods_name"
                    :thumb="item.goods_big_logo" @click="t(item.goods_id)" />
            </van-list>
        </van-pull-refresh>
    </div>
</template>

<script setup>
import { ref } from 'vue';
const onClickLeft = () => history.back();
import axios from 'axios';
import { useRouter, useRoute } from 'vue-router';
let router = new useRouter()
let route = new useRoute()
let arr = ref([])
axios.get('https://api-hmugo-web.itheima.net/api/public/v1/goods/search', { params: { cid: route.query.cid } }).then(res => {
    arr.value = res.data.message.goods
})
const t = (goods_id)=>{
        router.push({
        path: '/xqy',
        query: {
            // url的参数, 类似get请求的传参
            goods_id
        },
    })
}
</script>

<style></style>